//
//  WelcomeViewController.swift
//  Status
//
//  Created by 花轮 on 15/5/14.
//  Copyright (c) 2015年 花轮. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeViewController: UIViewController {

    @IBOutlet weak var bottomConstraint: NSLayoutConstraint!
    
    @IBOutlet weak var welcomeLabel: UILabel!
    @IBOutlet weak var iconView: UIImageView!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if let urlStr = sharedUserAccount?.avatar_large{
            iconView.sd_setImageWithURL(NSURL(string: urlStr))
        }
    }

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        bottomConstraint.constant = view.bounds.size.height - bottomConstraint.constant
        
        UIView.animateWithDuration(2.0, delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 5.0, options: nil, animations: {
            self.view.layoutIfNeeded()
        }) { _ in
            UIView.animateWithDuration(1.0, animations: {
                self.welcomeLabel.alpha = 1.0
            }, completion: { (_)  in
                NSNotificationCenter.defaultCenter().postNotificationName(LKSwitchRootViewControllerNotification, object: "Main")
            })
        }
        
    }
}
